package com.kfm.base.thread.day01;

public class Demo07 {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 4; i++) {
                System.out.println(i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        t1.start();

        try {
            // 在main执行， main线程等待 t1 执行完毕后再执行
            t1.join();
            // main线程等待 t1 执行 2s 后再执行
//            t1.join(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println("main end");
    }
}
